package project.web;

import project.service.TeacherService;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/updateTeacherPasswordServlet")
public class UpdateTeacherPasswordServlet extends HttpServlet {
    private TeacherService teacherService = new TeacherService();
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String teacherId = request.getParameter("teacherId");
        String password = request.getParameter("password");

//        System.out.println(teacherId);
//        System.out.println(password);
        boolean flag = teacherService.updateTeacherPassword(Long.parseLong(teacherId), password);

        if(flag){
            response.getWriter().write("success");
        }else{
            response.getWriter().write("unsuccess");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}
